package javaAPI.String;

import java.sql.SQLOutput;
import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        String rightUserName="zhangsan";
        String rightPassword="123456";
        for (int i=0;i<3;i++) {
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入用户名");
            String username=sc.next();
            System.out.println("请输入密码");
            String password=sc.next();
            if ((username.equals(rightUserName))&&(password.equals(rightPassword))) {
                System.out.println("用户登录成功");
                break;
            }else {
                if (i == 2) {
                    System.out.println("您的账户"+username+"被锁定，请联系程序员进行修复");
                } else {
                    System.out.println("用户登录失败，用户名或密码错误,您还剩下" + (2 - i) + "次机会");
                }
            }
        }
    }
}
